package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.xuehua.SnowflakeIdUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GradedAlarmReal;
import com.ruoyi.system.service.IGradedAlarmRealService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分级报警实时Controller
 * 
 * @author ruoyi
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/system/alarmReal")
public class GradedAlarmRealController extends BaseController
{
    @Autowired
    private IGradedAlarmRealService gradedAlarmRealService;

    /**
     * 查询分级报警实时列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarmReal:list')")
    @GetMapping("/list")
    public TableDataInfo list(GradedAlarmReal gradedAlarmReal)
    {
        startPage();
        List<GradedAlarmReal> list = gradedAlarmRealService.selectGradedAlarmRealList(gradedAlarmReal);
        return getDataTable(list);
    }

    /**
     * 导出分级报警实时列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarmReal:export')")
    @Log(title = "分级报警实时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GradedAlarmReal gradedAlarmReal)
    {
        List<GradedAlarmReal> list = gradedAlarmRealService.selectGradedAlarmRealList(gradedAlarmReal);
        ExcelUtil<GradedAlarmReal> util = new ExcelUtil<GradedAlarmReal>(GradedAlarmReal.class);
        util.exportExcel(response, list, "分级报警实时数据");
    }

    /**
     * 获取分级报警实时详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:alarmReal:query')")
    @GetMapping(value = "/{gradedAlramRealId}")
    public AjaxResult getInfo(@PathVariable("gradedAlramRealId") String gradedAlramRealId)
    {
        return success(gradedAlarmRealService.selectGradedAlarmRealByGradedAlramRealId(gradedAlramRealId));
    }

    /**
     * 新增分级报警实时
     */
    @PreAuthorize("@ss.hasPermi('system:alarmReal:add')")
    @Log(title = "分级报警实时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GradedAlarmReal gradedAlarmReal)
    {
        return toAjax(gradedAlarmRealService.insertGradedAlarmReal(gradedAlarmReal));
    }

    /**
     * 修改分级报警实时
     */
    @PreAuthorize("@ss.hasPermi('system:alarmReal:edit')")
    @Log(title = "分级报警实时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GradedAlarmReal gradedAlarmReal)
    {
        return toAjax(gradedAlarmRealService.updateGradedAlarmReal(gradedAlarmReal));
    }

    /**
     * 删除分级报警实时
     */
    @PreAuthorize("@ss.hasPermi('system:alarmReal:remove')")
    @Log(title = "分级报警实时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gradedAlramRealIds}")
    public AjaxResult remove(@PathVariable String[] gradedAlramRealIds)
    {
        return toAjax(gradedAlarmRealService.deleteGradedAlarmRealByGradedAlramRealIds(gradedAlramRealIds));
    }
}
